package com.skywolf.chem.article.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.skywolf.chem.article.entity.ContestNotice;
import com.skywolf.chem.article.mapper.ContestNoticeMapper;
import com.skywolf.chem.article.pojo.ContestQueryParam;
import com.skywolf.chem.article.pojo.LiveQueryParam;
import com.skywolf.chem.article.service.IContestNoticeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 赛事预告信息表 服务实现类
 * </p>
 *
 * @author 
 * @since 2020-07-01
 */
@Service
public class ContestNoticeServiceImpl extends ServiceImpl<ContestNoticeMapper, ContestNotice> implements IContestNoticeService {

    @Override
    public IPage<ContestNotice> liveNoticePageList(ContestQueryParam queryParam) {
        QueryWrapper<ContestNotice> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_deleted", 0);
        if(StringUtils.isNotBlank(queryParam.getTitle())){
            queryWrapper.and(wrapper -> wrapper.like("team_name1", queryParam.getTeamName()).or().like("team_name2", queryParam.getTeamName()));
        }
        if(StringUtils.isNotBlank(queryParam.getTitle())){
            queryWrapper.like("title", queryParam.getTitle());
        }
        if(StringUtils.isNotBlank(queryParam.getStartTime()) && StringUtils.isNotBlank(queryParam.getEndTime())){
            queryWrapper.between("start_time", queryParam.getStartTime(),queryParam.getEndTime());
        }
        return this.page(queryParam.page(), queryWrapper);
    }
}
